#!/usr/bin/python
# plot_logN.py

import math
import numpy
from matplotlib import use as useBackend
useBackend('Agg')
import matplotlib.pyplot as ppt


def cheat111():
    '''Cheat to clear the plot.'''
    ppt.subplot(311)
    ppt.plot([0,1],[1,2])
    ppt.subplot(131)
    ppt.plot([0,1],[1,2])
    ppt.subplot(111)


def plot(simpars, phypars, compN, N, allskyN):
    '''Shows a slice of GM_logN's results.'''
    for i in simpars:
        cmd = "%s = simpars['%s']" % (i,i)
        exec cmd
    for i in phypars:
        cmd = "%s = phypars['%s']" % (i,i)
        exec cmd
    # Plot two slices each for a bright and dim population
    brightN = N[0,:]
    dimN = N[-1,:]
    brightdata = N_bM[0,:]
    dimdata = N_bM[-1,:]
    brightcompN = compN[0,:]
    dimcompN = compN[-1,:]
    # N
    cheat111()
    ppt.hold(True)
    ppt.subplot(211)
    ppt.plot(ba, brightN)
    ppt.plot(bvals, brightdata, ls='None', marker='.')
    ppt.plot(bvals, brightcompN, ls='None', marker='.')
    ppt.ylabel('Log10 (bright stars per deg^2)')
    ppt.xlabel('b')
    ppt.subplot(212)
    ppt.plot(ba, dimN)
    ppt.plot(bvals, dimdata, ls='None', marker='.')
    ppt.plot(bvals, dimcompN, ls='None', marker='.')
    ppt.ylabel('Log10 (dim stars per deg^2)')
    ppt.xlabel('b')
    ppt.savefig('logcompNslices.pdf')
